package cn.buyclss.backend;

import cn.buyclss.backend.interceptor.CorsFilter;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;

@MapperScan({"cn.buyclss.backend.mapper"})
@PropertySource("classpath:documentation.properties")
@SpringBootApplication
public class BackendApplication {

    @Bean
    public FilterRegistrationBean setFilter() {
        FilterRegistrationBean filterBean = new FilterRegistrationBean();
        filterBean.setFilter(new CorsFilter());
        filterBean.setName("myCorsFilter");
        filterBean.addUrlPatterns("/*");
        filterBean.setOrder(0);
        return filterBean;
    }

    public static void main(String[] args) {
        SpringApplication.run(BackendApplication.class, args);
    }

}

